<template>
  <div class="_wz_accountSafetyFacilityDetails">

    <table cellpadding="0" cellspacing="0" border="0">
      <colgroup>
        <col width="13%">
        <col width="20%">
        <col width="13%">
        <col width="20%">
        <col width="13%">
        <col width="20%">
      </colgroup>
      <tbody>
      <tr>
        <td style="font-weight: 600;position:relative;" colspan="6">基本信息</td>
      </tr>
      <tr>
        <td>设施名称</td>
        <td colspan="2">{{!!formData.safetyFacilityName ? formData.safetyFacilityName:'--'}}</td>
        <td>设施编号</td>
        <td colspan="2">{{!!formData.safetyFacilityNo ? formData.safetyFacilityNo:'--'}}</td>
      </tr>
      <tr>
        <td>设施单位</td>
        <td colspan="2">{{!!formData.safetyFacilityUnit ? formData.safetyFacilityUnit:'--'}}</td>
        <td>设施数量</td>
        <td colspan="2">{{!!formData.safetyFacilityQuantity ? formData.safetyFacilityQuantity:'--'}}</td>
      </tr>
      <tr>
        <td>设施位置</td>
        <td colspan="2">{{!!formData.safetyFacilityPlace ? formData.safetyFacilityPlace:'--'}}</td>
        <td>设施负责人</td>
        <td colspan="2">{{!!formData.safetyFacilityDirector ? formData.safetyFacilityDirector:'--'}}</td>
      </tr>
      <tr>
        <td>登记时间</td>
        <td colspan="5">{{!!formData.safetyFacilityRegisterDate ? formData.safetyFacilityRegisterDate:'--'}}</td>
      </tr>
      </tbody>
    </table>
    <table cellpadding="0" cellspacing="0" border="0">
      <colgroup>
        <col width="10%">
        <col width="10%">
        <col width="20%">
        <col width="10%">
        <col width="20%">
        <col width="10%">
        <col width="20%">
      </colgroup>
      <tbody>
      <tr>
        <td style="font-weight: 600;position:relative;border-top: 0px;" colspan="7">保养记录</td>
      </tr>
      <template v-for="(item,index) in riskPlanItemList">
        <tr>
          <td rowspan="2"><Tag color="blue">第{{index+1}}项</Tag></td>
          <td>保养时间</td>
          <td>{{item.safetyFacilityMaintenanceDate}}</td>
          <td>保养情况</td>
          <td colspan="3">{{item.safetyFacilityMaintenanceSituation}}</td>
        </tr>
        <tr>
          <td>保养人</td>
          <td>{{item.safetyFacilityMaintenancePerson}}</td>
          <td>备注</td>
          <td colspan="3">{{item.remark}}</td>
        </tr>
      </template>
      </tbody>
    </table>




  </div>
</template>
<script>


import {
  getCurrentInstance,
  inject,
  nextTick,
  reactive,
  toRefs,
  toRef,
  onBeforeMount,
  onMounted,
  onBeforeUpdate,
  onUpdated,
  onBeforeUnmount,
  onUnmounted,
  ref,
  defineComponent,
  toRaw,
  watch,
  resolveComponent
} from 'vue'
import { useRouter,useRoute } from "vue-router";

import { useMainStore } from '../../../store'  //pinia 使用 类似 vuex
import { storeToRefs } from 'pinia'//pinia 使用 类似 vuex
const mainStore = useMainStore() //pinia 使用 类似 vuex

import wzTbale from "../../../components/table/index.vue";
//reactive
export default defineComponent({
  name: 'accountSafetyFacilityDetails',//组件名称
  components: {
    wzTbale,
  },//组件引用
  props: ['selectData'],//接收来自父组件的数据
  setup (props,context) {


    const apiUrl = inject('$apiUrl'); // 变量全局化 后台地址
    const $axios = inject('$axiosInterceptor');// 变量全局化 axios
    const $ViewUIPlus = inject('$ViewUIPlus');//引用全局组件
    const router = useRouter();//路由跳转使用


    const state = reactive({
      formData: {},//培训数据
      riskPlanItemList:[],//


    });

    //加载数据
    const loadData = ()=>{
      $axios.post(apiUrl.safetyAccountAccountSafetyFacilityMaintenancePageList,{facilityUuid:props.selectData.uuid}).then((res) => {
        if(!!res.data){
          state.riskPlanItemList = res.data.data;
        }

      }).catch((err) => {
        console.log("失败", err)
      })

    }



    // 其他的生命周期
    onBeforeMount (() => {//beforeMount挂载前状态 // console.log("App ===> 相当于 vue2.x 中 beforeMount")

    })
    onMounted (() => {//mounted 挂载结束状态  // console.log("App ===> 相当于 vue2.x 中 mounted")
      state.formData = props.selectData
      loadData()
    })

    // 注意，onBeforeUpdate 和 onUpdated 里面不要修改值
    onBeforeUpdate (() => {//beforeUpdate 更新前状态 // console.log("App ===> 相当于 vue2.x 中 beforeUpdate")

    })

    onUpdated (() => {//updated 更新完成状态 // console.log("App ===> 相当于 vue2.x 中 updated")

    })

    onBeforeUnmount (() => {//beforeDestroy 销毁前状态  // console.log("App ===> 相当于 vue2.x 中 beforeDestroy")
    })

    onUnmounted (() => {//destroyed 销毁完成状态  // console.log("App ===> 相当于 vue2.x 中 destroyed")
    })

    return {
      ...toRefs(state),
      apiUrl,
    }
  }
})


</script>
<style lang="less">

._wz_accountSafetyFacilityDetails {
  padding: 10px;
  height: 100%;
  display: flex;
  flex-direction: column;

  table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 12px !important;

    td {
      min-width: 0;
      height: 40px;
      box-sizing: border-box;
      text-align: left;
      text-overflow: ellipsis;
      border: 1px solid #515a6e;
      padding: 0 10px;
      word-break: break-word;
    }
  }
}
</style>
